﻿package mortal.game.view.lookPlayerInfo.view
{
    import Message.Public.*;
    import __AS3__.vec.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.utils.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.palyer.*;

    public class LookPlayerEquipPark extends GSprite
    {
        private var _equipmentList:Vector.<PlayerEquipItem>;
        protected var _equipTypeList:Array;
        protected var _equipTxt:GImageBitmap;

        public function LookPlayerEquipPark()
        {
            this._equipTypeList = [];
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._equipTxt = UIFactory.gImageBitmap(ImagesConst.playerModule_EquipTxt, -98, 55, this);
            this.resetEquipListPos();
            this.createEquipList();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            var _loc_2:PlayerEquipItem = null;
            for each (_loc_2 in this._equipmentList)
            {
                
                _loc_2.name = "";
                _loc_2.dispose(param1);
                _loc_2 = null;
            }
            this._equipTxt.dispose();
            this._equipTxt = null;
            this._equipTypeList.length = 0;
            super.disposeImpl(param1);
            return;
        }// end function

        protected function resetEquipListPos() : void
        {
            this._equipTypeList = [];
            this._equipTypeList[EEquip._EEquipHelmet] = {x:105, y:73, type:3};
            this._equipTypeList[EEquip._EEquipNecklace] = {x:25, y:50, type:1};
            this._equipTypeList[EEquip._EEquipShoulder] = {x:-69, y:165, type:1};
            this._equipTypeList[EEquip._EEquipAmulet] = {x:180, y:50, type:2};
            this._equipTypeList[EEquip._EEquipClothes] = {x:-69, y:225, type:1};
            this._equipTypeList[EEquip._EEquipWristlet] = {x:280, y:165, type:2};
            this._equipTypeList[EEquip._EEquipBelt] = {x:280, y:285, type:2};
            this._equipTypeList[EEquip._EEquipGlove] = {x:280, y:225, type:2};
            this._equipTypeList[EEquip._EEquipPants] = {x:-69, y:285, type:1};
            this._equipTypeList[EEquip._EEquipPendant] = {x:-35, y:100, type:1};
            this._equipTypeList[EEquip._EEquipShoe] = {x:280, y:345, type:2};
            this._equipTypeList[EEquip._EEquipRing] = {x:245, y:100, type:2};
            this._equipTypeList[EEquip._EEquipWeapon] = {x:-69, y:345, type:1};
            return;
        }// end function

        private function createEquipList() : void
        {
            var _loc_2:PlayerEquipItem = null;
            var _loc_3:int = 0;
            this._equipmentList = new Vector.<PlayerEquipItem>;
            var _loc_1:int = 13;
            while (_loc_3 < _loc_1)
            {
                
                _loc_2 = UICompomentPool.getUICompoment(PlayerEquipItem);
                _loc_2.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 3, 3);
                _loc_2.bgName = "EqmBg_" + _loc_3;
                _loc_2.name = "EquipsPanel_equip_" + _loc_3;
                _loc_2.isThrowAble = false;
                _loc_2.strengNumPosType = this._equipTypeList[_loc_3].type;
                _loc_2.x = this._equipTypeList[_loc_3].x;
                _loc_2.y = this._equipTypeList[_loc_3].y;
                this.addChild(_loc_2);
                this._equipmentList.push(_loc_2);
                _loc_3++;
            }
            return;
        }// end function

        private function getEquipByType(param1:int, param2:Array) : ItemData
        {
            var _loc_3:ItemData = null;
            var _loc_4:SPlayerItem = null;
            for each (_loc_4 in param2)
            {
                
                _loc_3 = new ItemData(_loc_4);
                if (_loc_3.itemInfo && _loc_3.itemInfo.type == param1)
                {
                    break;
                    continue;
                }
                _loc_3 = null;
            }
            return _loc_3;
        }// end function

        public function updateAllEquip(param1:Array, param2:Dictionary) : void
        {
            var _loc_4:PlayerEquipItem = null;
            var _loc_5:int = 0;
            var _loc_3:* = this._equipmentList.length;
            while (_loc_5 < _loc_3)
            {
                
                _loc_4 = this._equipmentList[_loc_5];
                _loc_4.itemData = this.getEquipByType(_loc_5, param1);
                if (_loc_4.itemData && _loc_4.itemData.itemInfo)
                {
                    _loc_4.buttonMode = true;
                    if (param2)
                    {
                        _loc_4.itemData.extData = param2[_loc_4.itemData.itemInfo.type];
                    }
                }
                else
                {
                    _loc_4.buttonMode = false;
                    _loc_4.toolTipData = GameDefConfig.instance.getEquipName(_loc_5);
                }
                _loc_4.updateStrengLevel();
                _loc_4.updateAroundEffect();
                _loc_5++;
            }
            return;
        }// end function

        public function clear() : void
        {
            var _loc_1:PlayerEquipItem = null;
            var _loc_2:int = 0;
            while (_loc_2 < this._equipmentList.length)
            {
                
                _loc_1 = this._equipmentList[_loc_2];
                _loc_1.itemData = null;
                _loc_1.buttonMode = false;
                _loc_1.toolTipData = GameDefConfig.instance.getEquipName(_loc_2);
                _loc_1.updateStrengLevel();
                _loc_1.updateAroundEffect();
                _loc_2++;
            }
            return;
        }// end function

    }
}
